# Definition for singly-linked list.
# 确定循环链表
class ListNode(object):
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution(object):
    def hasCycle(self, head):
        """
        :type head: ListNode
        :rtype: bool
        """
        if head ==None:
            return False
        q = head
        p = head
        while  p!=None and  p.next != None:
            q = q.next
            p = p.next.next
            if q==p:
                return True
        return False







l1 = ListNode(1)
# l1.next = ListNode(1)
# l1.next.next = l1
# l1.next.next.next = l1.next

m = Solution()
s = m.hasCycle(l1)
print(s)


